﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
public partial class Clients_Control_ykkh1 : System.Web.UI.UserControl
{
    private String strFaq = "<div class='question'><b>$Question</b></div><h5>$isTraloi</h5><div class='reply'>$Reply</div>";
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!this.IsPostBack)
        {
            LoadQuetion();
        }
    }
    private void LoadQuetion()
    {
        String strSql = "select bodyQuestion,bodyReply,isTraLoi from tbl_support"
            + " where isActive=1 order by addedDate Desc";
        DataTable tb = null;
        WebData db = new WebData();
        tb = db.tbl_Faqs.GetDataTableCache("faqQuetion", Constant.time, strSql, CommandType.Text);
        String url = "";
        foreach (DataRow row in tb.Rows)
        {
            String strQuetion = row["bodyQuestion"].ToString().Trim();
            String strReply = row["bodyReply"].ToString();
            if (!String.IsNullOrEmpty(strReply)) {
                strReply = strReply.Trim();
            }
            String strTraloi = Convert.ToBoolean(row["isTraLoi"].ToString()) == false ? "Chưa trả lời" : "Đã trả lời";
            url = url + strFaq.Replace("$Question", strQuetion).Replace("$Reply", strReply).Replace("$isTraloi",strTraloi);
        }

        lblFaq.Text = url;
        tb.Dispose();
    }
}